classdef AG3648A < DCSupply
    
    properties(Access = protected)
        driver;
        output;
    end
    

    
    methods
        function this = AG3648A(GPIB_controller, GPIB_address, address)
            this = this@DCSupply(GPIB_controller, GPIB_address, address);
            this.driver = icdevice('agilent_e3648a.mdd',this.conn);
            connect(this.driver);
            devicereset(this.driver);
            this.output = get(this.driver,'Output');
        end
        
        function delete(this)
            this.setOutputState('off',1);
            this.setOutputState('off',1);
            this.setVoltage(0,1);
            this.setVoltage(0,2);
            delete(this.driver);
            
        
        end
            
        
        function setVoltage(this, voltage,channel)
            this.voltage = voltage;
            this.channel = channel;
            set(this.output(this.channel),'VoltageLevel',this.voltage);
            
        end
        
        function setCurrentLimit(this, current_limit, channel)
            this.current_limit = current_limit;
            this.channel = channel;
            set(this.output(this.channel),'CurrentLimit',this.current_limit);
        end
        
        function setOutputState(this, output,channel)
             
             this.channel = channel;
             
             if output == 1 || strcmpi(output, 'on')
                 this.output_state = 'on'
                invoke(this.output,'enable');
             elseif output == 0 || strcmpi(output, 'off')
                this.output_state = 'off'
                invoke(this.output,'disable');
             end
        end
        
        function result = measureCurrent(this, channel)
            this.channel = channel;
            result = str2double(invoke(this.driver, 'measure', 'current'));
        end
        
         function result = measureVoltage(this, channel)
            this.channel = channel;
            result = str2double(invoke(this.driver, 'measure', 'voltage'));
         end
         
        
        
        
    end
            
    
end
